import ipfsAPI from 'ipfs-api'
const ipfs = ipfsAPI({host:'172.17.147.23', port:'5001', protocol:'http'})

export const  saveImageOnIpfs = (reader) => {
    return new Promise(function(resolve, reject) {
      const buffer = Buffer.from(reader.result);
      ipfs.add(buffer).then((response) => {
        // console.log(response)
        resolve(response[0].hash);
      }).catch((err) => {
        // console.error(err)
        reject(err);
      })
    })
  }